package com.zy.nft_system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.nft_system.domain.*;
import com.zy.nft_system.domain.dto.AccountDto;
import com.zy.nft_system.domain.dto.QntiqueauthDto;
import com.zy.nft_system.domain.dto.ZengAntique;
import com.zy.nft_system.service.QntiqueauthService;
import com.zy.nft_system.service.UserantiqueService;
import com.zy.nft_system.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author 这是那头猪？
 * @version 1.0
 * @description: TODO
 * @date 2022/12/7 16:02
 */
@RestController
@Slf4j
@RequestMapping("/Qqntiqueauth")
public class QntiqueauthController {

    @Autowired
    QntiqueauthService qntiqueauthService;

    @Autowired
    UserantiqueService userantiqueService;

    @PutMapping("/listCollection")
    public Result listCollection(@RequestBody QntiqueauthDto qntiqueauthDto){
        log.info("正在查询全部藏品信息");
        return qntiqueauthService.listCollection(qntiqueauthDto);
    }

    @GetMapping("/updataCollectionC")
    public Result updataCollectionC(Qntiqueauth qntiqueauth){
        log.info("正在修改藏品售卖状态");
        qntiqueauth.setModiftime(DateUtils.dataFormat(new Date()));
        boolean b = qntiqueauthService.updateById(qntiqueauth);
        if (!b){
            log.info("修改藏品售卖状态失败");
            return Result.error("修改藏品售卖状态失败");
        }
        log.info("修改藏品售卖状态成功");
        return Result.success("修改藏品售卖状态成功",null);
    }

    @GetMapping("/updataCollectionI")
    public Result updataCollectionI(Qntiqueauth qntiqueauth){
        log.info("正在修改藏品售卖状态");
        qntiqueauth.setModiftime(DateUtils.dataFormat(new Date()));
        boolean b = qntiqueauthService.updateById(qntiqueauth);
        if (!b){
            log.info("修改藏品转增状态失败");
            return Result.error("修改藏品转增状态失败");
        }
        log.info("修改藏品售卖状态成功");
        return Result.success("修改藏品转增状态成功",null);
    }

    @GetMapping("/listCollectionStatus1")
    public Result listCollectionStatus1(){
        log.info("正在查询全部在售藏品信息");
        return qntiqueauthService.listCollectionStatus1();
    }
    @GetMapping("/queryCoolectionById")
    public Result queryCoolectionById(int id){
        log.info("正在更具id查询全部在售藏品信息");
        return qntiqueauthService.queryCoolectionById(id);
    }

    @GetMapping("/queryUserCoolecById")
    public Result queryUserCoolecById(Integer uid){
        log.info("正在更具id查询用户藏品藏品信息");
        List<Userantique> userantiques = userantiqueService.list(new QueryWrapper<Userantique>().eq("uid", uid));
        if (userantiques.isEmpty()) {
            log.info("查询失败");
            return Result.error("查询失败");
        }
        log.info("查询成功");
        return Result.success("查询成功",userantiques);
    }
    @PostMapping("/zhuangzeng")
    public Result zhuangzeng(@RequestBody ZengAntique zengAntique){
        log.info("正在转增藏品");
        return qntiqueauthService.zhuangzeng(zengAntique);
    }
}
